<?php 
namespace FrontEnd\Model;

use Zend\Db\TableGateway\TableGateway;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Adapter\Adapter;
use Zend\Db\Sql\Select;
use App\Open\Recursive;
use Zend\Db\Adapter\AdapterAwareInterface;
use Zend\Db\ResultSet\HydratingResultSet;
use Zend\Cache\Service\StorageCacheAbstractServiceFactory;
use Zend\Log\LoggerAbstractServiceFactory;

class MenuTable extends AbstractTableGateway implements AdapterAwareInterface{
	protected $table = 'menu'; // tên bảng trong database
	
	public function setDbAdapter(Adapter $adapter){ // set apdater cho table
		$this->adapter = $adapter;
		$this->resultSetPrototype = new HydratingResultSet(); // đối tượng sẽ trả về khi lấy dữ liệu
		$this->initialize();
	}
	 
   public function fetchAll(){ // lấy toàn bộ dữ liệu của bảng menu
		$resultSet = $this->select(function (Select $select){
			$select->order(array('ID_M asc'));
			$select->where(array('TYPE_M'=>'F','ACTIVE_M'=>'1'));
		});

			$resultSet = $resultSet->toArray();
			return $resultSet;
			
	}

}
